import { createSymlink } from "fs-extra";
import router from "koa-router";
import { getEventData } from "../controller/event";

const eventRouter = new router({
  prefix: "/api/event",
});

eventRouter.get("/", async (ctx) => {
  const { label, startDate, endDate } = ctx.query;
  const res = await getEventData(
    { label },
    startDate as string,
    endDate as string,
  );
  ctx.status = (res as { code: number }).code === 99999 ? 400 : 200;
  ctx.body = res;
});

export default eventRouter;
